package work823;

import java.io.*;
import java.net.Socket;

public class work4Thread extends Thread {
  private Socket s;


  public work4Thread(Socket s) {
    this.s = s;
  }

  @Override
  public void run() {
    try {
      InputStream is = s.getInputStream();
      BufferedReader buf = new BufferedReader(new InputStreamReader(is));
      String str = buf.readLine();
      System.out.println(str);
      File file = new File(str);
      String str2 = "E:\\bdqn\\javaDemo\\"+file.getName();
      File file2 = new File(str2);
        file2.createNewFile();
        BufferedReader buf2 = new BufferedReader(new FileReader(file));
        BufferedWriter buw = new BufferedWriter(new FileWriter(file2));
        String s2 ;
        while ((s2=buf2.readLine())!= null){
          buw.write(s2);
          buw.newLine();
      }
      System.out.println("传输完成");
        buw.flush();
      s.shutdownOutput();
      s.shutdownInput();
    } catch (IOException e) {
      e.printStackTrace();
    }


  }
}
